home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2019 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: copy ctor and derived classes
  5. Date: 15 Jan 1996 14:26:33 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4ddo6p$3au@dawn.mmm.com>
  8. References: <DL38zz.50K@Virginia.EDU> <4d6u37$3b7@news.bridge.net>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. David Byrden (100101.2547@compuserve.com) wrote:
  13.  
  14. > Greg;
  15.  
  16. > >>  how can I invoke the base class's copy constructor in the
  17. > >> intialization list the derived class doesn't have to deal 
  18. > >> with all of the little bits of the base class?
  19.  
  20.  
  21. > The derived class has no RIGHT to deal with all the bits of the 
  22. > base class. They can be private.
  23.  
  24. > Here's what to do:
  25.  
  26.  
  27. > Derived::Derived( const Derived& rhs )      // copy ctor
  28. >  : Base( *this )                           // invoke base's copy ctor
  29. > {
  30.  
  31. > }
  32.  
  33. Even better would be to use Base(rhs) with instead of Base(*this) :-)
  34. --
  35. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  36. 3M Company                      phone:  (612) 737-4643
  37. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  38. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  39.     But 3M speaks for me -- I did not write the following line:
  40.  
  41. Opinions expressed herein are my own and may not represent those of 3M.
  42.